//
//  Myview.m
//  UI之下拉菜单
//
//  Created by dllo on 15/10/19.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "Myview.h"

@implementation Myview

- (void)dealloc {
    [_tableView release];
    [_array release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) style:UITableViewStylePlain];
        [self addSubview:self.tableView];
        self.tableView.backgroundColor = [UIColor cyanColor];
        [_tableView release];
        self.tableView.dataSource = self;
        self.tableView.delegate = self;
//
        self.tableView.hidden = YES;
        self.show = YES;
        self.button = [UIButton buttonWithType:UIButtonTypeSystem];
        self.button.frame = CGRectMake(100, 100, 100, 50);
        [self.button setTitle:@"下拉" forState:UIControlStateNormal];
        [self.button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;
}

- (void)click:(UIButton *)button {
    NSLog(@"333333");
    
    if (self.show) {
        self.tableView.hidden = NO;
        self.show = NO;
    } else {
        self.tableView.hidden = YES;
        self.show = YES;
    }
    
    
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *reuse = @"reuse";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuse] autorelease];
    }
    cell.textLabel.text = self.array[indexPath.row];
    return cell;
}


































/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
